package com.heima.test02;

import java.util.Random;

public class Gamer {
    private String name;
    private int blood;
    private char gender;
    private String face;

    //样貌
    String[] boyFace = {"帅的冒泡", "帅的抽风", "帅的一", "帅的扣jio"};
    String[] girlFace = {"美的冒泡", "美的抽风", "美的一", "美的扣jio"};

    //武功
    String[] kongFu = {"%s使用猴子偷桃向%s杀去","%s使用蛟龙出海向%s杀去","%s使用九阴白骨爪向%s杀去","%s使用666666向%s杀去","%s使用帅死你向%s杀去","%s使用美死你向%s杀去"};
    //受伤状态
    String[] hurted = {"嗷no%s的手受伤了","嗷no%s的腿受伤了","嗷no%s的腰受伤了","嗷no%s的头受伤了","%s软弱无力","%sgg了"};
    public char getGender() {
        return gender;
    }

    public Gamer(String name, int blood, char gender) {
        this.name = name;
        this.blood = blood;
        this.gender = gender;
        setFace(gender);//随机取的样貌
    }
    public void setFace(char gender) {
        //随机索引取样貌
        Random r = new Random();
        if (gender == '男') {
            int index = r.nextInt(boyFace.length);
            this.face = boyFace[index];
        }
        if (gender == '女') {
            int index = r.nextInt(girlFace.length);
            this.face = girlFace[index];
        } else {
            this.face = "牛鬼蛇神";
        }

    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String getFace() {
        return face;
    }

    public String[] getBoyFace() {
        return boyFace;
    }

    public void setBoyFace(String[] boyFace) {
        this.boyFace = boyFace;
    }

    public String[] getGirlFace() {
        return girlFace;
    }

    public void setGirlFace(String[] girlFace) {
        this.girlFace = girlFace;
    }

    public Gamer() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getBlood() {
        return blood;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }

    //打印信息
    public void gamerInfo() {
        System.out.println("姓名为：" + name);
        System.out.println("血量为：" + blood);
        System.out.println("性别为：" + gender);
        System.out.println("相貌为：" + face);
    }

    public void attack(Gamer gamer) {
        Random r = new Random();
        //定义索引
        int index = r.nextInt(kongFu.length);
        //取攻击效果
        String kungFU = kongFu[index];
        //输出攻击效果
        System.out.printf(kungFU,this.getName(),gamer.getName());
        //定义伤害
        int hurt = r.nextInt(20) + 1;
        //定义剩余血量
        int newBlood = this.blood - hurt;
        //剩余血量判断
        newBlood = newBlood < 0 ? 0 : newBlood;
        //判断之后将血量重新赋值
        gamer.setBlood(newBlood);
        //攻击之后换行
        System.out.println();
        //受伤的描述
        if (newBlood>90){
            System.out.printf(hurted[0],gamer.getName());
        }else if (newBlood>70){
            System.out.printf(hurted[1],gamer.getName());
        }else if (newBlood>50){
            System.out.printf(hurted[2],gamer.getName());
        }else if (newBlood>30){
            System.out.printf(hurted[3],gamer.getName());
        }else if (newBlood>10){
            System.out.printf(hurted[4],gamer.getName());
        }else if (newBlood == 0){
            System.out.printf(hurted[5],gamer.getName());
        }
        System.out.println();
    }
}
